﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Hotel.IRepository.Migrations
{
    public partial class rbac : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.RenameColumn(
                name: "U_Pwd",
                table: "Users",
                newName: "UserPwd");

            migrationBuilder.RenameColumn(
                name: "U_Name",
                table: "Users",
                newName: "UserName");

            migrationBuilder.RenameColumn(
                name: "U_Id",
                table: "Users",
                newName: "UserId");

            migrationBuilder.CreateTable(
                name: "Permissions",
                columns: table => new
                {
                    PermissionId = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    PermissionName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    PermissionTitle = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    PermissionPath = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    PermissionAction = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ParnentId = table.Column<int>(type: "int", nullable: false),
                    IsDel = table.Column<int>(type: "int", nullable: false),
                    Status = table.Column<int>(type: "int", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Permissions", x => x.PermissionId);
                });

            migrationBuilder.CreateTable(
                name: "RolePermisstionInfos",
                columns: table => new
                {
                    RolePermisstionId = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    UserToleId = table.Column<int>(type: "int", nullable: false),
                    PermissionId = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RolePermisstionInfos", x => x.RolePermisstionId);
                });

            migrationBuilder.CreateTable(
                name: "UserRoleInfos",
                columns: table => new
                {
                    UserToleId = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    RoleId = table.Column<int>(type: "int", nullable: false),
                    UserId = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserRoleInfos", x => x.UserToleId);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Permissions");

            migrationBuilder.DropTable(
                name: "RolePermisstionInfos");

            migrationBuilder.DropTable(
                name: "UserRoleInfos");

            migrationBuilder.RenameColumn(
                name: "UserPwd",
                table: "Users",
                newName: "U_Pwd");

            migrationBuilder.RenameColumn(
                name: "UserName",
                table: "Users",
                newName: "U_Name");

            migrationBuilder.RenameColumn(
                name: "UserId",
                table: "Users",
                newName: "U_Id");
        }
    }
}
